/*
 * Get a new XMLHttpRequest
 */
function newXMLHttpRequest() {
	var xmlreq = false;
	if (window.XMLHttpRequest) {
		xmlreq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		try {
			xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
			try {
				xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				xmlreq = false;
			}
		}
	}
	return xmlreq;
}

/*
 * set request to the handler
 */
function getReadyStateHandler(req, responseXmlHandler) {
	return function() {
		if (req.readyState == 4) {
			if (req.status == 200) {
				responseXmlHandler(req.responseXML);
			} else {
				alert("HTTP error " + req.status + ": " + req.statusText);
			}
		}
	};
}



/*
 * catch event and deal it with handler
 */ 
function catchEvent(eventObj, event, eventHandler) {
	  if (eventObj.addEventListener) {
		  eventObj.addEventListener(event, eventHandler, false);
	  } else if (eventObj.attachEvent) {
		  event = "on" + event;
		  eventObj.attachEvent(event, eventHandler);
	  }
}


function cancelEvent(event) {
	  if (event.preventDefault) {
		  event.preventDefault();
		  event.stopPropagation();
	  } else {
		  event.returnValue = false;
		  event.cancelBubble = true;
	  }
}

/*
 * setup events use catchEvent
 */
function setupEvents(evnt) {
	//catchEvent(document.getElementById("orderform"), "submit", login);
}

//setup events onload
//catchEvent(window, "load", setupEvents);